﻿using System;
using System.IO;
using EmbeddedSharp.Core.Logging;

namespace EmbeddedSharp.Core.Logging {
    public class TextLogger : ILogger, IDisposable {

        private StreamWriter sw = null;

        public TextLogger(string fileName) {
            sw = new StreamWriter(fileName, true);
        }

        #region ILogger Members

        public void WriteLog(string message, params string[] args) {
            sw.WriteLine(string.Format(message, args));
        }

        public void WriteLog(Exception ex) {
            sw.WriteLine(ex.Message + "\n" + ex.StackTrace);
        }

        #endregion

        #region IDisposable Members

        public void Dispose() {
            this.sw.Close();
        }

        #endregion
    }
}
